import { TweenCore } from "./TweenCore";
//class SimpleTimeline

    export  class SimpleTimeline extends TweenCore
    {
        constructor(arg1: Object=null)
        {
            super(0, arg1);
            return;
        }

        public addChild(arg1: TweenCore): void
        {
            if (!arg1.cachedOrphan && arg1.timeline) 
            {
                arg1.timeline.remove(arg1, true);
            }
            arg1.timeline = this;
            if (arg1.gc) 
            {
                arg1.setEnabled(true, true);
            }
            if (this._firstChild) 
            {
                this._firstChild.prevNode = arg1;
            }
            arg1.nextNode = this._firstChild;
            this._firstChild = arg1;
            arg1.prevNode = null;
            arg1.cachedOrphan = false;
            return;
        }

        public remove(arg1: TweenCore, arg2: Boolean=false): void
        {
            if (arg1.cachedOrphan) 
            {
                return;
            }
            if (!arg2) 
            {
                arg1.setEnabled(false, true);
            }
            if (arg1.nextNode) 
            {
                arg1.nextNode.prevNode = arg1.prevNode;
            }
            else if (this._lastChild == arg1) 
            {
                this._lastChild = arg1.prevNode;
            }
            if (arg1.prevNode) 
            {
                arg1.prevNode.nextNode = arg1.nextNode;
            }
            else if (this._firstChild == arg1) 
            {
                this._firstChild = arg1.nextNode;
            }
            arg1.cachedOrphan = true;
            return;
        }

        public /* override */ renderTime(arg1: number, arg2: Boolean=false, arg3: Boolean=false): void
        {
            var loc2=NaN;
            var loc3=null;
            var loc1=this._firstChild;
            this.cachedTotalTime = arg1;
            this.cachedTime = arg1;
            while (loc1) 
            {
                loc3 = loc1.nextNode;
                if (loc1.active || arg1 >= loc1.cachedStartTime && !loc1.cachedPaused && !loc1.gc) 
                {
                    if (loc1.cachedReversed) 
                    {
                        loc2 = loc1.cacheIsDirty ? loc1.totalDuration : loc1.cachedTotalDuration;
                        loc1.renderTime(loc2 - (arg1 - loc1.cachedStartTime) * loc1.cachedTimeScale, arg2, false);
                    }
                    else 
                    {
                        loc1.renderTime((arg1 - loc1.cachedStartTime) * loc1.cachedTimeScale, arg2, false);
                    }
                }
                loc1 = loc3;
            }
            return;
        }

        public get rawTime(): number
        {
            return this.cachedTotalTime;
        }

        protected /* var */_firstChild: TweenCore;

        protected /* var */_lastChild: TweenCore;

        public /* var */autoRemoveChildren: Boolean;
    }
